package com.kafka;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

/**
 * @author liyanhao
 * @Date 2023-02-18 19:01
 */
@Component
public class MyConsumer {
    @KafkaListener(topics = "my-replicated-topic", groupId = "zhangsanGroup")
    public void listenZhangsanGroup(ConsumerRecord<String, String> record, Acknowledgment acknowledgment) {
        String value = record.value();
        System.out.println(value);
        System.out.println(record);
        //手动提交offset
        acknowledgment.acknowledge();
    }
}
